<!-- 地点管理 - 综合表单页面 -->
<template>
  <div class="page-container">
    <page_breadcrumb :getKeyMethod="init_table_model" @change="change_table_model" pageOption/>
    <ex_super_table_page v-bind="option" ref="SuperTablePage" @selection-change="e => selection = e">
    </ex_super_table_page>

    <importView ref="importRef" @submitSuccess="$refs['SuperTablePage'].reload()"/>
  </div>
</template>
<script>
import importView from './dialog/import.vue';
import superTablePageFunction from '@/mixin/super-table-page-function';
import page_table_model_manage from '@/mixin/page_table_model_manage';
import emitOnFunction from '@/mixin/emit-on-function';

let emitKey = 'tms>service_network_manage'
export default {
  title: "label_network_manage",
  mixins: [superTablePageFunction, emitOnFunction(emitKey), page_table_model_manage],
  components: { importView },
  data() {
    return {
      selection: [],
      option: {
        search: {
          model: [
            {key: 'strFullIndex', label: 'label_network_query',},
            {key: 'placeCode', label: 'label_network_code',},
            {
              key: 'serviceOutletMode',
              label: 'label_network_mode',
              type: 'select',
              enum: 'TmsBaseServiceOutletModeEnum'
            },
            {key: 'parentPlaceId', label: 'label_network_belong',
            type: 'select',
             url:"/tms-api/base/TmsServiceOutletRpc/selectLikeServiceOutletLabel.json",
            option:(e) => ({ label: e.placeName, value: e.id })},
          ],
        },
        actionExtra: [
          {
            label: 'label_network_create', attrs: {icon: "el-icon-plus"},
            click: this.clickCreate
          },
          // {
          //   label: 'label_export',
          //   attrs: {type: "primary"},
          //   click: this.exportExcel
          // },
          // {
          //   label: 'label_import',
          //   attrs: {type: "primary"},
          //   click: this.importFn
          // },
        ],
        table: {
          url: "/tms-api/base/TmsServiceOutletRpc/selectPage.json",
          model: this.init_table_model(),
        }
      },
    };
  },
  methods: {
    option_table_model() {
      return [
        {type: 'selection', clickToggle: true,},

        {key: 'placeCode', label: 'label_network_code', 'min-width': 120, 'show-overflow-tooltip': true,},
        {key: 'placeName', label: 'label_network_name', 'min-width': 140, 'show-overflow-tooltip': true,},
        {key: 'address', label: 'label_network_address', 'min-width': 180, 'show-overflow-tooltip': true,},
        {key: 'parentPlaceName', label: 'label_network_belong', 'min-width': 120, 'show-overflow-tooltip': true},
        {key: 'serviceOutletCenterName', label: 'label_network_center', 'min-width': 120, 'show-overflow-tooltip': true},
        {
          key: 'serviceOutletHeadOfficeName',
          label: 'label_network_belong_head_office',
          'min-width': 120,
          'show-overflow-tooltip': true,
        },
        {
          key: 'serviceOutletMode', label: 'label_network_mode', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "TmsBaseServiceOutletModeEnum")
        },
        {
          key: 'serviceOutletType', label: 'label_network_type', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "TmsBaseServiceOutletTypeEnum")
        },
        {
          key: 'placeLocation', label: 'label_network_position', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "TmsBasePlacePositionEnum")
        },
        {key: 'contacts', label: 'label_srm_supplier_contact_name', 'min-width': 120, 'show-overflow-tooltip': true},
        {
          key: 'contactNumber',
          label: 'label_srm_supplier_contact_phone',
          'min-width': 120,
          'show-overflow-tooltip': true
        },
        // {key: 'address', label: 'label_network_address', 'min-width': 120, 'show-overflow-tooltip': true,},
        {
          key: 'serviceRangeRemark',
          label: 'label_service_range_remark',
          'min-width': 120,
          'show-overflow-tooltip': true,
        },
        {key: 'financialCenter', label: 'label_financial_center', 'min-width': 120, 'show-overflow-tooltip': true,},
        {
          key: 'distributionCenter',
          label: 'label_distribution_center',
          'min-width': 120,
          'show-overflow-tooltip': true,
        },
        {
          key: 'allowArrivePay', label: 'label_allow_arrive_pay', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "YesOrNoEnum")
        },
        {
          key: 'isPrepayEnabled', label: 'label_pre_pay_enable', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "IsAvailableStatusEnum")
        },
        {
          key: 'status', label: 'label_status', 'min-width': 120, 'show-overflow-tooltip': true,
          formatter: (r, c, v, i) => this.$enumShow(v, "IsAvailableStatusEnum")
        },
        {key: 'modifier', label: 'label_update_user', 'min-width': 120, 'show-overflow-tooltip': true,},
        {
          key: 'gmtModify', label: 'label_modify_time', 'min-width': 120, 'show-overflow-tooltip': true,
          attrs: {
            formatter: (r, c, v, i) => {
              return this.$dateFormat(v)
            }
          }
        },
        {
          type: 'operate', width: 160, operate: [
            {
              label: 'label_view_detail',
              click: (row) => {this.$router.push({path: './detail', query: {id: row.id, edit: true, emitKey}}) }
            },
            {
              label: 'label_edit',
              click: (row) => this.clickEdit(row)
            },
            {
              if: (row) => row.status == 'ENABLE',
              auth: 'tms_place_manage_disable',
              label: 'label_stop_using',
              type: "confirm-button",
              buttonClass: "button_text_danger",
              confirmButtonType: 'danger',
              url: '/tms-api/base/TmsServiceOutletRpc/updateStatus.json',
              message: 'text_confirm_sure_stop_using_operate',
              params: (row) => {
                return {"id": row["id"], "status": "DISABLED"}
              },
              done: ['reload', 'tip']
            },
            {
              if: (row) => row.status == 'DISABLED',
              auth: 'tms_place_manage_disable',
              label: 'label_start_using',
              type: "confirm-button",
              buttonClass: "button_text_success",
              confirmButtonType: 'success',
              url: '/tms-api/base/TmsServiceOutletRpc/updateStatus.json',
              message: 'text_confirm_sure_start_using_operate',
              params: (row) => {
                return {"id": row["id"], "status": "ENABLE"}
              },
              done: ['reload', 'tip']
            },
            {
              label: 'label_delete',
              type: "confirm-button", buttonClass: "button_text_danger", confirmButtonType: 'danger',
              url: '/tms-api/base/TmsServiceOutletRpc/remove.json', message: 'text_confirm_sure_delete',
              params: (row) => {
                return {"id": row["id"]}
              }, done: ['reload', 'tip']
            },
          ],
        }
      ]
    },
    clickCreate() {
      this.$router.push({path: './operate', query: {emitKey}})
    },
    clickEdit(row) {
      this.$router.push({path: './operate', query: {id: row.id, edit: true, emitKey}})
    },
    exportExcel() {
      this.$downloadFile({
        loading: true,
        type: 'json',
        url: '/tms-api/base/TmsServiceOutletRpc/exportExcel.json',
        data: {
          placeIds: this.selection.map(it => it.id),
          ...this.getSuperTablePage().getSearchFormData()
        },
      })
    },
    importFn() {
      this.$refs.importRef.show()
    }
  }
};

</script>
<style></style>

